![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@thi.ng/random
Advanced tools
Readme
[!NOTE] This is one of 193 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.
🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️
Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation.
This package provides the IRandom
interface and various (mostly seedable)
pseudo-random number generator implementations, incl. IRandom
wrappers for
Math.random()
and window.crypto
:
Partially ported from C implementations taken from c.thi.ng.
coin()
/ fairCoin()
pickRandom()
/ pickRandomKey()
randomBytes()
/ randomBytesFrom()
randomID()
weightedRandom()
/ weightedRandomKey()
uniqueIndices()
/ uniqueValuesFrom()
uuidv4Bytes()
/ uuid()
STABLE - used in production
Search or submit any issues for this package
yarn add @thi.ng/random
ESM import:
import * as rnd from "@thi.ng/random";
Browser ESM import:
<script type="module" src="https://esm.run/@thi.ng/random"></script>
For Node.js REPL:
const rnd = await import("@thi.ng/random");
Package sizes (brotli'd, pre-treeshake): ESM: 2.02 KB
Several projects in this repo's /examples directory are using this package:
Screenshot | Description | Live demo | Source |
---|---|---|---|
![]() | Self-modifying, animated typographic grid with emergent complex patterns | Demo | Source |
![]() | Probabilistic color theme generator | Demo | Source |
![]() | Interactive inverse FFT toy synth | Demo | Source |
![]() | 2D Bezier curve-guided particle system | Demo | Source |
![]() | Basic hiccup-based canvas drawing | Demo | Source |
![]() | Barnsley fern IFS fractal renderer | Demo | Source |
![]() | k-means clustering visualization | Demo | Source |
![]() | Randomized space-filling, nested grid layout generator | Demo | Source |
![]() | Randomized 4-point 2D color gradient image generator | Demo | Source |
![]() | Interactive pixel sorting tool using thi.ng/color & thi.ng/pixel | Demo | Source |
![]() | Animated, iterative polygon subdivisions & visualization | Demo | Source |
![]() | Procedural stochastic text generation via custom DSL, parse grammar & AST transformation | Demo | Source |
![]() | Basic usage of thi.ng/rdom keyed list component wrapper | Demo | Source |
![]() | Generative audio synth offline renderer and WAV file export | Demo | Source |
![]() | Evolutionary shader generation using genetic programming | Demo | Source |
![]() | Responsive & reactively computed stacked column layout | Demo | Source |
![]() | Game of Life implemented as WebGL2 multi-pass shader pipeline | Demo | Source |
import { Smush32 } from "@thi.ng/random";
const rnd = new Smush32(0xdecafbad);
// the following methods are available for all generators
// next uint (0 .. 2^32-1)
rnd.int()
// 4022849029
// next float [0.0 .. 1.0)
rnd.float()
// 0.2698542904737066
// next normalized float (w/ opt scale)
// [-scale .. +scale)
rnd.norm(100)
// 57.70723665079737
// next float in given interval [min .. max)
rnd.minmax(10, 20)
// 15.295951807707537
rnd.minmaxInt(10, 20)
If this project contributes to an academic publication, please cite it as:
@misc{thing-random,
title = "@thi.ng/random",
author = "Karsten Schmidt",
note = "https://thi.ng/random",
year = 2015
}
© 2015 - 2024 Karsten Schmidt // Apache License 2.0
FAQs
Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation
The npm package @thi.ng/random receives a total of 77,328 weekly downloads. As such, @thi.ng/random popularity was classified as popular.
We found that @thi.ng/random demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.